home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.1 (Developer) [x86] / NeXT Step 3.1 Intel dev.cdr.dmg / NextDeveloper / Headers / bsd / dev / fd_extern.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-30  |  17.6 KB  |  690 lines

  1. /*    @(#)fd_extern.h     2.0    01/25/90    (c) 1990 NeXT    
  2.  *
  3.  * fd_vars.h -- Externally used data structures and constants for Floppy 
  4.  *        Disk driver
  5.  *
  6.  * KERNEL VERSION
  7.  *
  8.  * HISTORY
  9.  * 20-Mar-91    Doug Mitchell
  10.  *    Made #importing  pmap.h and vm_map.h dependent on #ifdef KERNEL.
  11.  * 25-Jan-90    Doug Mitchell at NeXT
  12.  *    Created.
  13.  *
  14.  */
  15.  
  16. #ifndef    _FDEXTERN_
  17. #define _FDEXTERN_
  18.  
  19. #import <sys/types.h>
  20. #import <sys/ioctl.h>
  21. #ifdef    KERNEL
  22. #import <machdep/machine/pmap.h>
  23. #import <vm/vm_map.h>
  24. #endif    KERNEL
  25. #import <mach/boolean.h>
  26. #import <mach/vm_param.h>
  27.  
  28. #define FD_CMDSIZE    0x10        /* max size of command passed to 
  29.                      * controller */
  30. #define FD_STATSIZE    0x10        /* max size of status array returned
  31.                      * from controller */
  32.                      
  33. typedef    int fd_return_t;        /* see FDR_xxx, below */
  34.  
  35. struct fd_drive_stat {
  36.     u_char        media_id:2,    /* media type currently inserted. See
  37.                      * FD_MID_xxx, below. */
  38.              motor_on:1,    /* state of motor at I/O complete 
  39.                      * 1 = on; 0 = off */
  40.             write_prot:1,    /* write protect 1 = Write Protected */
  41.             drive_present:1,
  42.             rsvd1:3;    /* reserved */
  43. };
  44.  
  45. /*
  46.  * I/O request struct. Used in DKIOCREQ ioctl to specify one command sequence
  47.  * to be executed.
  48.  */
  49. struct fd_ioreq {
  50.     /* 
  51.      * inputs to driver:
  52.      */
  53.     u_char        density;    /* see FD_DENS_xxx, below */
  54.     int        timeout;    /* I/O timeout in milliseconds. Used
  55.                      * in FDCMD_CMD_XFR commands only. */
  56.     int        command;    /* see FDCMD_xxx, below */
  57.     u_char        cmd_blk[FD_CMDSIZE];
  58.                     /* actual command bytes */
  59.     u_int        num_cmd_bytes;    /* expected # of bytes in cmd_blk[] to
  60.                      * transfer */
  61.     caddr_t        addrs;        /* source/dest of data */
  62.     u_int        byte_count;    /* max # of data bytes to move */
  63.     u_char        stat_blk[FD_STATSIZE];
  64.                     /* status returned from controller */
  65.     u_int        num_stat_bytes;    /* number of status bytes to transfer
  66.                      * to stat_blk[] */
  67.     int         flags;        /* see FD_IOF_xxx, below */
  68.     
  69.     /*
  70.      * outputs from driver:
  71.      */
  72.     fd_return_t    status;        /* FDR_SUCCESS, etc. */
  73.     u_int        cmd_bytes_xfr;    /* # of command bytes actually moved */
  74.     u_int        bytes_xfr;    /* # of data bytes actually moved */
  75.     u_int        stat_bytes_xfr;    /* # if status bytes moved to 
  76.                      * stat_blk[] */
  77.     struct fd_drive_stat drive_stat; /* media ID, etc. */
  78.  
  79.     /*
  80.      * used internally by driver
  81.      */
  82. #ifdef    KERNEL
  83.     pmap_t        pmap;        /* DMA is mapped by this */
  84.     vm_map_t    map;        /* map of requestor's task */
  85. #else    KERNEL
  86.     void        *pmap;
  87.     void        *map;
  88. #endif    KERNEL
  89.     u_char        unit;        /* drive # (relative to controller) */
  90. };
  91.  
  92. typedef struct fd_ioreq fdIoReq_t;    
  93. typedef struct fd_ioreq *fd_ioreq_t;
  94.  
  95. /*
  96.  * fd_ioreq.command values 
  97.  */
  98. #define FDCMD_BAD        0x00    /* not used */
  99. #define FDCMD_CMD_XFR        0x01    /* transfer command in fd_ioreq.cmd_blk
  100.                      */
  101. #define FDCMD_EJECT        0x02    /* eject disk */
  102. #define FDCMD_MOTOR_ON        0x03    /* motor on */
  103. #define FDCMD_MOTOR_OFF        0x04    /* motor off */
  104. #define FDCMD_GET_STATUS    0x05    /* Get status (media ID, motor state,
  105.                      * write protect) */
  106.  
  107. /*
  108.  * fd_ioreq.density values. Some routines rely on these being in
  109.  * cardinal order...
  110.  */
  111. #define FD_DENS_NONE    0        /* unformatted */
  112. #define FD_DENS_1    1        /* 1 MByte/disk unformatted */
  113. #define FD_DENS_2    2        /* 2 MByte/disk unformatted */
  114. #define FD_DENS_4    3        /* 4 MByte/disk unformatted */
  115.  
  116. #if     i386
  117. #define FD_DENS_DEFAULT    FD_DENS_2
  118. #else
  119. #define FD_DENS_DEFAULT FD_DENS_4
  120. #endif
  121.  
  122. /*
  123.  * fd_ioreq.flags values
  124.  */
  125. #define FD_IOF_DMA_DIR        0x00000002
  126. #define FD_IOF_DMA_RD        0x00000002    /* DMA direction = device to
  127.                          * host */
  128. #define FD_IOF_DMA_WR        0x00000000    /* DMA direction = host to
  129.                          * device */
  130.                          
  131. /*
  132.  * fdr_return_t values
  133.  */
  134. #define FDR_SUCCESS        0    /* OK */
  135. #define FDR_TIMEOUT        1    /* fd_ioreq.timeout exceeded */
  136. #define FDR_MEMALLOC        2    /* couldn't allocate memory */
  137. #define FDR_MEMFAIL        3    /* memory transfer error */
  138. #define FDR_REJECT        4    /* bad field in fd_ioreq */
  139. #define FDR_BADDRV        5    /* drive not present */
  140. #define FDR_DATACRC        6    /* media error - data CRC */
  141. #define FDR_HDRCRC        7    /* media error - header CRC */
  142. #define FDR_MEDIA        8    /* misc. media error */
  143. #define FDR_SEEK         9    /* seek error */
  144. #define FDR_BADPHASE        10    /* controller changed phase 
  145.                      * unexpectedly */
  146. #define FDR_DRIVE_FAIL        11    /* Basic Drive Failure */
  147. #define FDR_NOHDR        12    /* Header Not Found */
  148. #define FDR_WRTPROT        13    /* Disk Write Protected */
  149. #define FDR_NO_ADDRS_MK        14    /* Missing Address Mark */
  150. #define FDR_CNTRL_MK        15    /* Missing Control Mark */
  151. #define FDR_NO_DATA_MK        16    /* Missing Data Mark */
  152. #define FDR_CNTRL_REJECT    17    /* controller rejected command */
  153. #define FDR_CNTRLR        18    /* Controller Handshake Error */
  154. #define FDR_DMAOURUN        19    /* DMA Over/underrun */
  155. #define FDR_VOLUNAVAIL        20    /* Requested Volume not available */
  156. #define FDR_ALIGN        21    /* DMA alignment error */
  157. #define FDR_DMA            22    /* DMA error */
  158. #define FDR_SPURIOUS        23    /* spurious interrupt */
  159.  
  160. /*
  161.  * fd_drive_stat.media_id values
  162.  */
  163. #define FD_MID_NONE        0    /* no disk inserted */
  164. #define FD_MID_1MB        3    /* 1 MByte unformatted */
  165. #define FD_MID_2MB        2    /* 2 MByte unformatted */
  166. #define FD_MID_4MB        1    /* 4 MBytes unformatted */
  167.  
  168. #if i386
  169. #define FD_MID_DEFAULT    FD_MID_2MB
  170. #define FD_MAX_DMA_SIZE        PAGE_SIZE /* Maximum Number of bytes of data
  171.                           that can be transfered via DMA 
  172.                            using FDIOCREQ ioctl command
  173.                        */
  174.  
  175. #endif
  176.  
  177. /*
  178.  * ioctl's specific to floppy disk
  179.  */
  180. #define    FDIOCREQ    _IOWR('f', 0, struct fd_ioreq)    /* cmd request */
  181. #define FDIOCGFORM    _IOR ('f', 1, struct fd_format_info)
  182.                             /* get format */
  183. #define FDIOCSDENS    _IOW ('f', 2, int)        /* set density */
  184. #define FDIOCSSIZE    _IOW ('f', 3, int)        /* set sector size */
  185. #define FDIOCSGAPL    _IOW ('f', 4, int)        /* set Gap 3 length */
  186. #define FDIOCRRW    _IOWR('f', 5, struct fd_rawio)    /* raw read/write */
  187. #define FDIOCSIRETRY    _IOW ('f', 6, int)        /* set inner retry loop
  188.                              * count */
  189. #define FDIOCGIRETRY    _IOR ('f', 7, int)        /* get inner retry loop
  190.                              * count */
  191. #define FDIOCSORETRY    _IOW ('f', 8, int)        /* set outer retry loop
  192.                              * count */
  193. #define FDIOCGORETRY    _IOR ('f', 9, int)        /* get outer retry loop
  194.                              * count */
  195. /*
  196.  *     software registers passed to controller during command sequences 
  197.  */
  198.  
  199. struct fd_rw_cmd {
  200.     /*
  201.      * 9 command bytes passed at start of read/write data
  202.      */
  203.      
  204. #if     __LITTLE_ENDIAN__
  205.  
  206.     u_char  opcode:5,
  207.         sk:1,            /* skip sectors with deleted AM */
  208.         mfm:1,            /* MFM encoding */
  209.         mt:1;             /* multi track */
  210.     u_char    drive_sel:2,        /* drive select */
  211.         hds:1,            /* head select */
  212.          rsvd1:5;        /* reserved */
  213.     u_char    cylinder;
  214.     u_char    head;
  215.     u_char    sector;
  216.     u_char    sector_size;        /* 'n' in the Intel spec. */
  217.     u_char    eot;            /* sector # at end of track */
  218.     u_char    gap_length;        /* gap length */
  219.     u_char    dtl;            /* special sector size */
  220.  
  221. #elif    __BIG_ENDIAN__
  222.  
  223.     u_char     mt:1,            /* multitrack */
  224.         mfm:1,            /* MFM encoding */
  225.         sk:1,            /* skip sectors with deleted AM */
  226.         opcode:5;
  227.     u_char    rsvd1:5,        /* reserved */
  228.         hds:1,            /* head select */
  229.         drive_sel:2;        /* drive select */
  230.     u_char    cylinder;
  231.     u_char    head;
  232.     u_char    sector;
  233.     u_char    sector_size;        /* 'n' in the Intel spec. */
  234.     u_char    eot;            /* sector # at end of track */
  235.     u_char    gap_length;        /* gap length */
  236.     u_char    dtl;            /* special sector size */
  237.     
  238. #else
  239. #error    Floppy command / data structures are compiler sensitive
  240. #endif
  241. };
  242.  
  243. #define SIZEOF_RW_CMD    9        /* compiler yields 9 as sizeof this
  244.                      * struct */
  245.                      
  246. struct fd_rw_stat {
  247.     /* 
  248.      * 7 status bytes passed at completion of read/write data 
  249.      */
  250.  
  251.     u_char    stat0;
  252.     u_char    stat1;
  253.     u_char     stat2;
  254.     u_char    cylinder;
  255.     u_char    head;
  256.     u_char    sector;
  257.     u_char    sector_size;        /* 'n' in the Intel spec. */
  258. };
  259.  
  260. #define SIZEOF_RW_STAT    7
  261.  
  262. struct fd_int_stat {
  263.     /* 
  264.      * result of Sense Interrupt Status command
  265.      */
  266.     u_char     stat0;    
  267.     u_char    pcn;            /* present cylinder & */
  268. };
  269.  
  270. struct fd_seek_cmd {
  271.     /* 
  272.      * Seek command. Uses Sense Interrupt Status to get results.
  273.      */
  274.      
  275. #if     __LITTLE_ENDIAN__
  276.  
  277.     u_char    opcode:6,        /* will be FCCMD_SEEK */
  278.         dir:1,            /* 1 == towards spindle for 
  279.                         relative seek*/
  280.         relative:1;        /* 1 = relative */
  281.     u_char    drive_sel:2,        /* drive select */
  282.         hds:1,            /* head select */
  283.         rsvd1:5;        /* reserved */
  284.     u_char    cyl;            /* cylinder # or offset */
  285.     
  286. #elif    __BIG_ENDIAN__
  287.  
  288.     u_char    relative:1,        /* 1 = relative */
  289.         dir:1,            /* 1 == towards spindle */
  290.         opcode:6;        /* will be FCCMD_SEEK */
  291.     u_char    rsvd1:5,        /* reserved */
  292.         hds:1,            /* head select */
  293.         drive_sel:2;        /* drive select */
  294.     u_char    cyl;            /* cylinder # or offset */
  295.     
  296. #else
  297. #error    Floppy command / data structures are compiler sensitive
  298. #endif
  299. };
  300.  
  301. #define SEEK_DIR_IN        1        /* seek towards spindle */
  302. #define SEEK_DIR_OUT        0        /* seek away from spindle */
  303.  
  304. #define SIZEOF_SEEK_CMD        3
  305.  
  306. struct fd_recal_cmd {
  307.     /* 
  308.      * Recalibrate command. Uses Sense Interrupt Status to get results.
  309.      */
  310.     u_char    opcode;            /* will be FCCMD_RECAL */
  311.     
  312. #if     __LITTLE_ENDIAN__
  313.  
  314.     u_char    drive_sel:2,        /* drive select */
  315.         rsvd1:6;        /* reserved */
  316.     
  317. #elif    __BIG_ENDIAN__
  318.  
  319.     u_char    rsvd1:6,        /* reserved */
  320.         drive_sel:2;        /* drive select */
  321.     
  322. #else
  323. #error    Floppy command / data structures are compiler sensitive
  324. #endif
  325. };
  326.     
  327. struct fd_configure_cmd {
  328.     /*
  329.      * configure command. No result bytes are returned.
  330.      */
  331.     u_char     opcode;            /* will be FCCMD_CONFIGURE */
  332.     u_char    rsvd1;            /* must be 0 */
  333.     u_char     conf_2;            /* EIS, EFIFO, etc. */
  334.     u_char    pretrk;            /* write precomp track # */
  335. };
  336.  
  337. /*
  338.  * configure command fields 
  339.  */
  340. #define CF2_EIS            0x40    /* enable implied seek */
  341. #define CF2_EFIFO        0x20    /* enable FIFO. True Low. */
  342. #define CF2_DPOLL        0x10    /* disable polling */
  343. #define CF2_FIFO_DEFAULT    0x08    /* OUR default FIFO threshold */
  344. #define CF_PRETRACK        0x00    /* OUR default precom track */
  345. #define I82077_FIFO_SIZE    0x10    /* size of FIFO */
  346.  
  347. struct fd_specify_cmd {
  348.     /*
  349.      * Specify command. No result bytes are returned.
  350.      */
  351.     u_char     opcode;            /* will be FCCMD_SPECIFY */
  352.     
  353. #if     __LITTLE_ENDIAN__
  354.  
  355.     u_char     hut:4,            /* head unload time */
  356.         srt:4;            /* step rate */
  357.     u_char    nd:1,            /* Non-DMA mode */
  358.         hlt:7;            /* head load time */
  359.     
  360. #elif    __BIG_ENDIAN__
  361.  
  362.     u_char    srt:4,            /* step rate */
  363.          hut:4;            /* head unload time */
  364.     u_char    hlt:7,            /* head load time */
  365.         nd:1;            /* Non-DMA mode */
  366.     
  367. #else
  368. #error    Floppy command / data structures are compiler sensitive
  369. #endif
  370. };
  371.  
  372. #define SIZEOF_SPECIFY_CMD    3
  373.  
  374. struct fd_readid_cmd {
  375.     /* 
  376.      * Read ID command. Returns status in an fd_rw_stat.
  377.      */
  378.      
  379. #if     __LITTLE_ENDIAN__
  380.  
  381.     u_char    opcode:6,        /* Will be FCCMD_READID */
  382.         mfm:1,
  383.          rsvd1:1;
  384.     u_char    drive_sel:2,        /* drive select */
  385.         hds:1,            /* head select */
  386.         rsvd2:5;        /* reserved */
  387.     
  388. #elif    __BIG_ENDIAN__
  389.  
  390.     u_char     rsvd1:1,
  391.         mfm:1,
  392.         opcode:6;        /* Will be FCCMD_READID */
  393.     u_char    rsvd2:5,        /* reserved */
  394.         hds:1,            /* head select */
  395.         drive_sel:2;        /* drive select */
  396.     
  397. #else
  398. #error    Floppy command / data structures are compiler sensitive
  399. #endif
  400. };
  401.  
  402. struct fd_perpendicular_cmd {
  403.     u_char    opcode;            /* will be FCCMD_PERPENDICULAR */
  404.     
  405. #if     __LITTLE_ENDIAN__
  406.  
  407.     u_char    gap:1,
  408.         wgate:1,
  409.         rsvd1:6;        /* must be 0 */
  410.     
  411. #elif    __BIG_ENDIAN__
  412.  
  413.     u_char    rsvd1:6,        /* must be 0 */
  414.         wgate:1,
  415.         gap:1;
  416.     
  417. #else
  418. #error    Floppy command / data structures are compiler sensitive
  419. #endif
  420. };
  421.  
  422. struct fd_format_cmd {
  423.     /*
  424.      * Format track command. Returns status in an fd_rw_stat
  425.      * (with undefined address fields).
  426.      */
  427.      
  428. #if     __LITTLE_ENDIAN__
  429.  
  430.     u_char    opcode:6,        /* will be FCCMD_FORMAT */
  431.         mfm:1,
  432.         rsvd1:1;
  433.     u_char    drive_sel:2,        /* drive select */
  434.         hds:1,            /* head select */
  435.         rsvd2:5;        /* reserved */
  436.     
  437. #elif    __BIG_ENDIAN__
  438.  
  439.     u_char    rsvd1:1,
  440.         mfm:1,
  441.         opcode:6;        /* will be FCCMD_FORMAT */
  442.     u_char    rsvd2:5,        /* reserved */
  443.         hds:1,            /* head select */
  444.         drive_sel:2;        /* drive select */
  445.     
  446. #else
  447. #error    Floppy command / data structures are compiler sensitive
  448. #endif
  449.     u_char    n;            /* sector size (2**n * 128 = sect_size)
  450.                      */
  451.     u_char    sects_per_trk;
  452.     u_char    gap_length;
  453.     u_char    filler_data;        /* data field written with this byte */
  454. };
  455.  
  456. struct fd_sense_drive_status_cmd {
  457.     /*
  458.      * returns one result byte which is basically status register 3
  459.      */
  460.  
  461.     u_char    opcode;     /* will be FCCMD_DRIVE_STATUS */
  462.     
  463. #if     __LITTLE_ENDIAN__
  464.  
  465.     u_char    drive_sel:2,    /* drive select */
  466.         hds:1,        /* head select */
  467.          resvd2:5;     /* always zero */
  468.     
  469. #elif    __BIG_ENDIAN__
  470.  
  471.     u_char    resvd2:5,     /* always zero */
  472.         hds:1,        /* head select */
  473.          drive_sel:2;    /* drive select */
  474.     
  475. #else
  476. #error    Floppy command / data structures are compiler sensitive
  477. #endif
  478. };
  479.  
  480. /*
  481.  *    software register values
  482.  */
  483.  
  484. /*
  485.  * cmd (command byte). Not all of these opcodes are used with the fd_rw_cmd 
  486.  * struct...
  487.  */
  488. #define FCCMD_OPCODE_MASK    0x1F
  489. #define    FCCMD_MULTITRACK    0x80
  490. #define FCCMD_MFM        0x40        /* MFM flag */
  491. #define FCCMD_SK        0x20        /* skip flag */
  492. #define FCCMD_READ        0x06
  493. #define FCCMD_READ_DELETE    0x0C
  494. #define FCCMD_WRITE        0x05
  495. #define FCCMD_WRITE_DELETE    0x09
  496. #define FCCMD_READ_TRACK    0x02
  497. #define FCCMD_VERIFY        0x16
  498. #define FCCMD_VERSION        0x10
  499. #define FCCMD_FORMAT        0x0D
  500. #define FCCMD_RECAL        0x07
  501. #define FCCMD_INTSTAT        0x08        /* sense interrupt status */
  502. #define FCCMD_SPECIFY        0x03
  503. #define FCCMD_DRIVE_STATUS    0x04
  504. #define FCCMD_SEEK        0x0F
  505. #define FCCMD_CONFIGURE        0x13
  506. #define FCCMD_DUMPREG        0x0E
  507. #define FCCMD_READID        0x0A        /* Read ID */
  508. #define FCCMD_PERPENDICULAR    0x12        /* perpendicular recording mode
  509.                          */
  510. /* 
  511.  * rws_stat0 (status register 0)
  512.  */
  513. #define SR0_INTCODE        0xC0    /* interrupt code - see INTCODE_xxx */
  514. #define INTCODE_COMPLETE    0x00    /* normal I/O complete */
  515. #define INTCODE_ABNORMAL    0x40    /* abnormal termination */
  516. #define INTCODE_INVALID        0x80    /* Invalid command */
  517. #define INTCODE_POLL_TERM    0xC0    /* abnormal termination caused by 
  518.                      * polling */
  519. #define SR0_SEEKEND        0x20    /* Seek End */
  520. #define SR0_EQ_CHECK        0x10    /* Equipment check (recal failed,
  521.                      *    seek beyond track 0, etc.) */
  522. #define SR0_HEAD        0x04    /* current head address */
  523. #define SR0_DRVSEL        0x03
  524. #define SR0_DRVSEL1        0x02    /* Drive Select 1 */
  525. #define SR0_DRVSEL0        0x01    /* Drive Select 0 */
  526.  
  527. /*
  528.  * rws_stat1 (status register 1)
  529.  */
  530. #define SR1_EOCYL        0x80    /* end of cylinder */
  531. #define SR1_CRCERR        0x20    /* data or ID CRC error */
  532. #define SR1_OURUN        0x10    /* DMA over/underrun */
  533. #define SR1_NOHDR        0x04    /* Header Not Found */
  534. #define SR1_NOT_WRT        0x02    /* Not writable */
  535. #define SR1_MISS_AM        0x01    /* Missing Address mark */
  536.  
  537. /*
  538.  * rws_stat2 (status register 2)
  539.  */
  540. #define SR2_CNTRL_MK        0x40    /* control mark */
  541. #define SR2_DATACRC        0x20    /* Data CRC error */
  542. #define SR2_WRONG_CYL        0x10    /* wrong cylinder */
  543. #define SR2_BAD_CYL        0x02    /* Bad cylinder */
  544. #define SR2_MISS_AM        0x01    /* missing data mark */
  545.  
  546. /*
  547.  * rws_stat3 (status register 3)
  548.  */
  549. #define SR3_WP            0x40    /* write protected */
  550. #define SR3_TRACK0        0x10    /* Track 0 */
  551. #define SR3_HEAD        0x04    /* Head # */
  552. #define SR3_DRVSEL1        0x02    /* same as status register 0?? */
  553. #define SR3_DEVSEL0        0x01    
  554.  
  555. /*
  556.  * disk info - maps media_id to tracks_per_cyl and num_cylinders.
  557.  */
  558. struct fd_disk_info {
  559.     u_int     media_id;            /* FD_MID_1MB, etc. */
  560.     u_char    tracks_per_cyl;            /* # of heads */
  561.     u_int    num_cylinders;    
  562.     u_int    max_density;            /* maximum legal density.
  563.                          * (FD_DENS_1, etc.) */
  564. };
  565.  
  566. /*
  567.  * sector size info - maps sector size to 82077 sector size code and
  568.  * gap3 length.  Note that the controller must be programmed for different
  569.  * gap3 size when formatting as opposed to reading or writing.  Since gap3
  570.  * sizes may be dependent on the actual disk hardware, the fmt gap is
  571.  * maintained here to avoid requiring the formatter to determine
  572.  * the disk device type.
  573.  */
  574. struct fd_sectsize_info {
  575.     u_int         sect_size;        /* in bytes */
  576.     u_char        n;            /* 82077 sectsize code */
  577.     u_int        sects_per_trk;        /* physical sectors per trk */
  578.     u_char        rw_gap_length;        /* Gap 3 for rw cmds */ 
  579.     u_char        fmt_gap_length;        /* Gap 3 for fmt cmds */ 
  580. };
  581.  
  582. typedef struct fd_sectsize_info fd_sectsize_info_t;
  583.  
  584. /*
  585.  * density info - maps density to capacity. Note that a disk may be formatted
  586.  * with a lower density than its max possible density.
  587.  */
  588. struct fd_density_info {
  589.     u_int         density;        /* FD_DENS_1, etc. */
  590.     u_int         capacity;        /* in bytes */
  591.     boolean_t    mfm;            /* TRUE = MFM encoding */
  592. };
  593.  
  594. typedef struct fd_density_info fd_density_info_t;
  595.  
  596. /*
  597.  * disk format info. Used with ioctl(FDIOCGFORM).
  598.  */
  599. struct fd_format_info {
  600.     /*
  601.      * the disk_info struct is always valid as long as a disk is
  602.      * inserted.
  603.      */
  604.     struct fd_disk_info    disk_info;
  605.     
  606.     int            flags;        /* See FFI_xxx, below */
  607.  
  608.     /*
  609.      * the remainder is only valid if (flags & FFI_FORMATTED) is true.
  610.      */
  611.     struct fd_density_info    density_info;
  612.     struct fd_sectsize_info    sectsize_info;
  613.     u_int            total_sects;    /* total # of sectors on 
  614.                          * disk */
  615. };
  616.  
  617. /*
  618.  * fd_format_info.flags fields
  619.  */
  620. #define FFI_FORMATTED        0x00000001    /* known disk format */
  621. #define FFI_LABELVALID        0x00000002    /* Valid NeXT file system label
  622.                          * present */
  623. #define FFI_WRITEPROTECT    0x00000004    /* disk is write protected */
  624.                          
  625. struct format_data {
  626.     /* 
  627.      * one of these per sector. A Format command involves DMA'ing one of 
  628.      * these for each sector on a track. The format command is executed
  629.      * with a FDIOCREQ ioctl.
  630.      */
  631.     u_char cylinder;
  632.     u_char head;
  633.     u_char sector;
  634.     u_char n;            /* as in sector_size = 2**n * 128 */
  635. };
  636.  
  637. /*
  638.  * result of FCCMD_DUMPREG command
  639.  */
  640. struct fd_82077_regs {
  641.     u_char    pcn[4];        /* cylinder # for drives 0..3 */
  642.     u_char    srt:4,
  643.         hut:4;
  644.     u_char    hlt:7,
  645.         nd:1;
  646.     u_char    sc_eot;
  647.     u_char    rsvd1;
  648.     u_char    rsvd2:1,
  649.         eis:1,
  650.         efifo:1,
  651.         poll:1,
  652.         fifothr:4;
  653.     u_char    pretrk;
  654. };
  655.  
  656. /*
  657.  * Used for FDIOCRRW - raw disk I/O 
  658.  * -- no bad block mapping
  659.  * -- no label required
  660.  * -- no front porch 
  661.  * -- block size = physical sector size
  662.  */
  663. struct fd_rawio {
  664.     /*
  665.      * Passed to driver
  666.      */
  667.     u_int         sector;
  668.     u_int        sector_count;
  669.     caddr_t        dma_addrs;
  670.     boolean_t    read;        /* TRUE = read; FALSE = write */
  671.     /*
  672.      * Returned from driver
  673.      */
  674.     fd_return_t    status;        /* FDR_xxx (see above) */
  675.     u_int         sects_xfr;    /* sectors actually moved */
  676. };
  677.  
  678. /*
  679.  * misc. hardware constants
  680.  */
  681. #define NUM_FD_HEADS     2        /* number of tracks/cylinder */
  682. #define NUM_FD_CYL    80        /* cylinders/disk (is this actually a 
  683.                      * constant for all densities?) */
  684. #define FD_PARK_TRACK    79        /* track to which to seek before
  685.                      * eject */
  686. #define NUM_UNITS    4        /* max # of drives per controller */ 
  687.  
  688. #endif    _FDEXTERN_
  689.  
  690.